﻿<Window xmlns:ListBloodSugar="clr-namespace:NetDayHospital.Core.Controls.ListBloodSugar;assembly=NetDayHospital.Core"
        x:Class="BloodSugar.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:BloodSugar"
        xmlns:DateStartEnd="clr-namespace:NetDayHospital.Core.Controls.DateStartEnd;assembly=NetDayHospital.Core"
        mc:Ignorable="d"
        FontSize="14"
        Title="MainWindow"
        Height="550"
        Width="900">

    <Window.DataContext>
        <local:MainWindowModel />
    </Window.DataContext>

    <Window.Resources>
        <Style x:Key="TextBoxError"
               TargetType="TextBox">
            <Setter Property="Margin"
                    Value="0, 0, 35, 0" />
            
            <Setter Property="Validation.ErrorTemplate">
                <Setter.Value>
                    <ControlTemplate>
                        <DockPanel LastChildFill="true">

                            <Border Background="red"
                                    DockPanel.Dock="right"
                                    Margin="5,0,0,0"
                                    Width="20"
                                    Height="20"
                                    CornerRadius="10"
                                    ToolTip="{Binding ElementName=customAdorner,
                                                      Path=AdornedElement.(Validation.Errors)[0].ErrorContent,
                                                      UpdateSourceTrigger=PropertyChanged}"
                                                      ToolTipService.InitialShowDelay="1">

                                <TextBlock Text="?"
                                           VerticalAlignment="center"
                                           HorizontalAlignment="center"
                                           FontWeight="Bold"
                                           Foreground="white" />

                            </Border>
                            <AdornedElementPlaceholder Name="customAdorner" />

                        </DockPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>

    <Grid Margin="20">
        <!--<Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>-->
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="400" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <StackPanel Grid.Column="0"
                    Orientation="Vertical">            

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Column="0"
                           Margin="15, 0, 5, 0"
                           Text="Ф.И.О:" />

                <TextBox Grid.Column="1"
                         Style="{StaticResource TextBoxError}"
                         Text="{Binding FullName, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
            </Grid>

            <Separator Opacity="0"
                       Height="10" />

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Column="0"
                           Margin="15, 0, 5, 0"
                           Text="Дата рождения:" />

                <TextBox Grid.Column="1"
                         Style="{StaticResource TextBoxError}"
                         Width="150"
                         Text="{Binding BirthDateFull, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                         Margin="0,0,125,0" />
            </Grid>

            <Separator Opacity="0"
                       Height="10" />

            <DateStartEnd:DateStartEndView DataContext="{Binding DateStartEndViewModel}" />

            <Separator Opacity="0"
                       Height="10" />

            <TextBlock Text="Значения сахара" HorizontalAlignment="Center" />

            <StackPanel Orientation="Horizontal">

                <RadioButton GroupName="Sugar"
                             VerticalAlignment="Center"
                             Content="Очень высокое"
                             IsChecked="{Binding Path=RadioButton1, Mode=TwoWay}" />

                <Separator Opacity="0"
                           Width="10" />

                <RadioButton GroupName="Sugar"
                             VerticalAlignment="Center"
                             Content="Высокое"
                             IsChecked="{Binding Path=RadioButton2, Mode=TwoWay}" />

                <Separator Opacity="0"
                           Width="10" />

                <RadioButton GroupName="Sugar"
                             VerticalAlignment="Center"
                             Content="Нормальное"
                             IsChecked="{Binding Path=RadioButton3, Mode=TwoWay}" />

                <Separator Opacity="0"
                           Width="20" />

                <ToggleButton HorizontalAlignment="Center"
                              IsChecked="{Binding CountListChecked}"
                              Margin="5"
                              Padding="5"
                              Width="80">                    
                    <ToggleButton.Style>
                        <Style TargetType="{x:Type ToggleButton}">
                            <Setter Property="Content"
                                    Value="Короткий" />
                            <Style.Triggers>
                                <Trigger Property="IsChecked"
                                         Value="True">
                                    <Setter Property="Content"
                                            Value="Полный" />
                                    <!--<Setter Property="Foreground"
                                            Value="Green" />-->
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </ToggleButton.Style>
                </ToggleButton>

            </StackPanel>

            <Button Content="Печать"
                    Command="{Binding PrintCommand}" />

        </StackPanel>

        <ListBloodSugar:ListBloodSugarView Grid.Column="2"
                                           Margin="10,0,10,0"
                                           DataContext="{Binding ListBloodSugarViewModel}" />

    </Grid>

</Window>
